Developer --> Technical Publications
PATHHardware Documentation > USB Devices > Mac OS USB DDK API Reference


Finding A Pipe

After the functions used to open the interface have completed, you need to work out which already open pipe in the interface is the one you want to communicate through.

USBFindNextPipe

The USBFindNextPipe function can be used to either find a specific pipe, as specified by the direction in the usbFlags field and type in the usbClassType field, or to search through the available pipes.

OSStatus USBFindNextPipe(USBPB *pb);

Required fields required the USBPB parameter block for the USBFindNextPipe function are

--> pbLength
Length of parameter block
--> pbVersion
Parameter block version number
--> usbCompletion
The completion routine
--> usbRefcon
General-purpose value passed back to the completion routine
<--> usbReference
--> Interface or pipe reference <-- Pipe reference
-- usbBuffer
Should be set to 0 (0 returned); reserved in this call
-- usbActCount
Should be set to 0 (0 returned); reserved in this call
-- usbReqCount
Should be set to 0 (0 returned); reserved in this call
<--> usbFlags
--> Specific direction of pipe ( kUSBIn or kUSBOut ) or kUSBAnyDirn as a wildcard <-- Direction of input or output pipe
<--> usbClassType
--> Specific endpoint type ( kUSBControl, kUSBInterrupt, or kUSBBulk ) or kUSBAnyType as a wildcard <-- Endpoint type
<-- usbWValue
Maximum packet size of endpoint

This function takes either an interface or pipe reference in the usbReference field. To find the first pipe, make a call to the function with an interface reference. To find the next pipe, enter the pipe reference returned by the previous call.

The usbFlags field takes either a specified endpoint direction or a wildcard of kUSBAnyDirn . The usbClassType field takes either a specified endpoint type or a wildcard of kUSBAnyType . For example, if you specify values for an input interrupt pipe, the function returns only the input interrupt pipes found. If a wildcard is used, all pipes of any type and direction found are returned.

Errors returned by the USBFindNextPipe function include

paramErr usbBuffer pointer, usbReqCount, or usbActCount fields are not set to 0
kUSBUnknownDeviceErr -6998 usbReference does not refer to a current device
kUSBUnknownPipeErr -6997 pipe reference specified is unknown
kUSBNotFound -6987 interface or configuration specified is not in configuration descriptor

© 1998 Apple Computer, Inc. – (Last Updated 23 Nov 98)

Previous | Back Up One Level | Next |